summaryrefslogtreecommitdiffstats
path: root/src/video_core/host_shaders/vulkan_turbo_mode.comp
blob: d651001d9d4e22e11fba58da92d5e69b69fbafd6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#version 460 core

layout (local_size_x = 16, local_size_y = 8, local_size_z = 1) in;

layout (binding = 0) buffer ThreadData {
    uint data[];
};

uint xorshift32(uint x) {
    x ^= x << 13;
    x ^= x >> 17;
    x ^= x << 5;
    return x;
}

uint getGlobalIndex() {
    return gl_GlobalInvocationID.x + gl_GlobalInvocationID.y * gl_WorkGroupSize.y * gl_NumWorkGroups.y;
}

void main() {
    uint myIndex = xorshift32(getGlobalIndex());
    uint otherIndex = xorshift32(myIndex);

    uint otherValue = atomicAdd(data[otherIndex % data.length()], 0) + 1;
    atomicAdd(data[myIndex % data.length()], otherValue);
}